import java.util.ArrayList;
import java.util.List;

public class SoilMoistureSensor {
    private final List<SensorObserver> observers = new ArrayList<>();
    private double moisture = 50.0; // 默认湿度
    
    public void addObserver(SensorObserver observer) {
        observers.add(observer);
    }
    
    public void setMoisture(double moisture) {
        this.moisture = moisture;
        notifyObservers();
    }
    
    private void notifyObservers() {
        for (SensorObserver observer : observers) {
            observer.update(moisture);
        }
    }
    
    public double getMoisture() {
        return moisture;
    }
}